﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using UnityEngine;

// Token: 0x02000324 RID: 804
[Serializable]
public class AssetBundleData
{
	// Token: 0x06001440 RID: 5184 RVA: 0x0008E310 File Offset: 0x0008C510
	public AssetBundleData()
	{
	}

	// Token: 0x06001441 RID: 5185 RVA: 0x0008E330 File Offset: 0x0008C530
	public AssetBundleData(string bundle, string asset)
	{
		this.bundle = bundle;
		this.asset = asset;
	}

	// Token: 0x170001EF RID: 495
	// (get) Token: 0x06001442 RID: 5186 RVA: 0x0008E35C File Offset: 0x0008C55C
	public bool isEmpty
	{
		get
		{
			return this.bundle.IsNullOrEmpty() || this.asset.IsNullOrEmpty();
		}
	}

	// Token: 0x06001443 RID: 5187 RVA: 0x0008E37C File Offset: 0x0008C57C
	public bool Check(string bundle, string asset)
	{
		return (!asset.IsNullOrEmpty() && this.asset != asset) || (!bundle.IsNullOrEmpty() && this.bundle != bundle);
	}

	// Token: 0x170001F0 RID: 496
	// (get) Token: 0x06001444 RID: 5188 RVA: 0x0008E3BC File Offset: 0x0008C5BC
	public virtual LoadedAssetBundle LoadedBundle
	{
		get
		{
			string text;
			return AssetBundleManager.GetLoadedAssetBundle(this.bundle, out text, null);
		}
	}

	// Token: 0x170001F1 RID: 497
	// (get) Token: 0x06001445 RID: 5189 RVA: 0x0008E3D8 File Offset: 0x0008C5D8
	public bool isFile
	{
		get
		{
			return this.LoadedBundle != null || File.Exists(AssetBundleManager.BaseDownloadingURL + this.bundle);
		}
	}

	// Token: 0x170001F2 RID: 498
	// (get) Token: 0x06001446 RID: 5190 RVA: 0x0008E404 File Offset: 0x0008C604
	public virtual string[] AllAssetNames
	{
		get
		{
			LoadedAssetBundle loadedBundle = this.LoadedBundle;
			AssetBundle assetBundle;
			if (loadedBundle != null)
			{
				assetBundle = loadedBundle.m_AssetBundle;
			}
			else
			{
				assetBundle = AssetBundle.LoadFromFile(AssetBundleManager.BaseDownloadingURL + this.bundle);
			}
			IEnumerable<string> allAssetNames = assetBundle.GetAllAssetNames();
			if (AssetBundleData.callback0 == null)
			{
				AssetBundleData.callback0 = new Func<string, string>(Path.GetFileNameWithoutExtension);
			}
			string[] result = allAssetNames.Select(AssetBundleData.callback0).ToArray<string>();
			if (loadedBundle == null)
			{
				assetBundle.Unload(true);
			}
			return result;
		}
	}

	// Token: 0x06001447 RID: 5191 RVA: 0x0008E480 File Offset: 0x0008C680
	public static List<string> GetAssetBundleNameListFromPath(string path, bool subdirCheck = false)
	{
		List<string> result = new List<string>();
		string basePath = AssetBundleManager.BaseDownloadingURL;
		string path2 = basePath + path;
		if (!Directory.Exists(path2))
		{
			return result;
		}
		string[] files;
		if (subdirCheck)
		{
			files = Directory.GetFiles(path2, "*.unity3d", SearchOption.AllDirectories);
		}
		else
		{
			files = Directory.GetFiles(path2, "*.unity3d");
		}
		return (from s in files
		select s.Replace(basePath, string.Empty)).ToList<string>();
	}

	// Token: 0x06001448 RID: 5192 RVA: 0x0008E4FC File Offset: 0x0008C6FC
	public virtual AssetBundleLoadAssetOperation LoadBundle<T>() where T : UnityEngine.Object
	{
		if (!this.isFile)
		{
			return null;
		}
		AssetBundleLoadAssetOperation result;
		if ((result = this.request) == null)
		{
			result = (this.request = AssetBundleManager.LoadAsset(this, typeof(T)));
		}
		return result;
	}

	// Token: 0x06001449 RID: 5193 RVA: 0x0008E53C File Offset: 0x0008C73C
	public virtual AssetBundleLoadAssetOperation LoadBundleAsync<T>() where T : UnityEngine.Object
	{
		if (!this.isFile)
		{
			return null;
		}
		AssetBundleLoadAssetOperation result;
		if ((result = this.request) == null)
		{
			result = (this.request = AssetBundleManager.LoadAssetAsync(this, typeof(T)));
		}
		return result;
	}

	// Token: 0x0600144A RID: 5194 RVA: 0x0008E57C File Offset: 0x0008C77C
	public virtual AssetBundleLoadAssetOperation LoadAllBundle<T>() where T : UnityEngine.Object
	{
		if (!this.isFile)
		{
			return null;
		}
		AssetBundleLoadAssetOperation result;
		if ((result = this.request) == null)
		{
			result = (this.request = AssetBundleManager.LoadAllAsset(this, typeof(T)));
		}
		return result;
	}

	// Token: 0x0600144B RID: 5195 RVA: 0x0008E5BC File Offset: 0x0008C7BC
	public virtual AssetBundleLoadAssetOperation LoadAllBundleAsync<T>() where T : UnityEngine.Object
	{
		if (!this.isFile)
		{
			return null;
		}
		AssetBundleLoadAssetOperation result;
		if ((result = this.request) == null)
		{
			result = (this.request = AssetBundleManager.LoadAllAssetAsync(this, typeof(T)));
		}
		return result;
	}

	// Token: 0x0600144C RID: 5196 RVA: 0x0008E5FC File Offset: 0x0008C7FC
	public virtual T GetAsset<T>() where T : UnityEngine.Object
	{
		if (this.request == null)
		{
			this.request = this.LoadBundle<T>();
		}
		if (this.request == null)
		{
			return (T)((object)null);
		}
		return this.request.GetAsset<T>();
	}

	// Token: 0x0600144D RID: 5197 RVA: 0x0008E634 File Offset: 0x0008C834
	public virtual T[] GetAllAssets<T>() where T : UnityEngine.Object
	{
		if (this.request == null)
		{
			this.request = this.LoadAllBundle<T>();
		}
		if (this.request == null)
		{
			return null;
		}
		return this.request.GetAllAssets<T>();
	}

	// Token: 0x0600144E RID: 5198 RVA: 0x0008E668 File Offset: 0x0008C868
	public IEnumerator GetAsset<T>(Action<T> act) where T : UnityEngine.Object
	{
		if (this.request == null)
		{
			this.request = this.LoadBundleAsync<T>();
		}
		if (this.request == null)
		{
			yield break;
		}
		yield return this.request;
		if (this.request.IsEmpty())
		{
			yield break;
		}
		act.Call(this.request.GetAsset<T>());
		yield break;
	}

	// Token: 0x0600144F RID: 5199 RVA: 0x0008E68C File Offset: 0x0008C88C
	public IEnumerator GetAllAssets<T>(Action<T[]> act) where T : UnityEngine.Object
	{
		if (this.request == null)
		{
			this.request = this.LoadBundleAsync<T>();
		}
		if (this.request == null)
		{
			yield break;
		}
		yield return this.request;
		if (this.request.IsEmpty())
		{
			yield break;
		}
		act.Call(this.request.GetAllAssets<T>());
		yield break;
	}

	// Token: 0x06001450 RID: 5200 RVA: 0x0008E6B0 File Offset: 0x0008C8B0
	public virtual void UnloadBundle(bool isUnloadForceRefCount = false, bool unloadAllLoadedObjects = false)
	{
		if (this.request != null)
		{
			AssetBundleManager.UnloadAssetBundle(this, isUnloadForceRefCount, unloadAllLoadedObjects);
		}
		this.request = null;
	}

	// Token: 0x170001F3 RID: 499
	// (get) Token: 0x06001451 RID: 5201 RVA: 0x0008E6CC File Offset: 0x0008C8CC
	protected static bool isSimulation
	{
		get
		{
			return false;
		}
	}

	// Token: 0x06001452 RID: 5202 RVA: 0x0008E6D0 File Offset: 0x0008C8D0
	[Conditional("BASE_LOADER_LOG")]
	private void LogError(string str)
	{
		GlobalData.Debug_LogError(str + " isn't loaded successfully");
	}

	// Token: 0x040018E9 RID: 6377
	public string bundle = string.Empty;

	// Token: 0x040018EA RID: 6378
	public string asset = string.Empty;

	// Token: 0x040018EB RID: 6379
	protected AssetBundleLoadAssetOperation request;

	// Token: 0x040018EC RID: 6380
	[CompilerGenerated]
	private static Func<string, string> callback0;
}
